# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(avro)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

set(CMAKE_BUILD_WITH_INSTALL_RPATH true)

# 安全防护参数
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -D_FORTIFY_SOURCE=2 -ftrapv -s")
# 链接参数
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--disable-new-dtags")

add_library(avro_napi SHARED
            napi/avro_napi_init.cpp
            napi/avro_napi.cpp
            napi/avro_frombuffer.cpp
            napi/avro_compare.cpp
            utils/napi/napi_utils.cpp
            )

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/napi)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils/napi)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils/ohos_log)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/avro)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jansson)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/avro/${OHOS_ARCH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jansson/${OHOS_ARCH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/${OHOS_ARCH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib/${OHOS_ARCH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/xz/${OHOS_ARCH}/include)

target_link_libraries(avro_napi PUBLIC EGL)
target_link_libraries(avro_napi PUBLIC GLESv3)
target_link_libraries(avro_napi PUBLIC libace_napi.z.so hilog_ndk.z.so)
target_link_libraries(avro_napi PUBLIC ace_ndk.z)
target_link_libraries(avro_napi PUBLIC uv)
target_link_libraries(avro_napi PRIVATE z)
target_link_libraries(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/avro/${OHOS_ARCH}/lib/libavro.a)
target_link_libraries(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jansson/${OHOS_ARCH}/lib/libjansson.a)
target_link_libraries(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/${OHOS_ARCH}/lib/libsnappy.a)
target_link_libraries(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/xz/${OHOS_ARCH}/lib/liblzma.a)

target_include_directories(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/avro/${OHOS_ARCH}/include)
target_include_directories(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jansson/${OHOS_ARCH}/include)
target_include_directories(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/${OHOS_ARCH}/include)
target_include_directories(avro_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/xz/${OHOS_ARCH}/include)

